package com.pb.web.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.pb.entity.User;

public class LoginAction extends ActionSupport implements SessionAware {

	private User user;
	private Map<String, Object> session;

	/**
	 * 获取 user
	 * 
	 * @return user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user
	 * 
	 * @param user
	 *            user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	@Override
	public String execute() throws Exception {
		if (user.getUsername().equals("admin")&&user.getPassword().equals("123")) {
			session.put("user", user);
			return SUCCESS;
		}
		return ERROR;
	}

}
